home *** CD-ROM | disk | FTP | other *** search
/ Games Central GT Digital… Q3 Premier Trimestre '98 / GT_DPK.ISO / pc / data / menu.dxr / 00040_Scroll Text behavior.ls < prev    next >
Encoding:
Text File  |  1995-08-25  |  2.0 KB  |  52 lines

  1. property pTextSprite, pTextMember, pScrollRange, pTextLineHeight, pWindowTop, pWindowHeight
  2.  
  3. on beginSprite me
  4.   set pTextSprite to the spriteNum of me
  5.   set pWindowTop to the locV of sprite pTextSprite
  6.   set pTextMember to the member of sprite pTextSprite
  7.   set memberLength to the height of member pTextMember
  8.   set halfWindow to integer(0.5 * pWindowHeight)
  9.   set pScrollRange to memberLength - halfWindow
  10.   set the locV of sprite pTextSprite to pWindowTop
  11. end
  12.  
  13. on scrollText me, direction, scrollType
  14.   case 1 of
  15.     voidp(scrollType):
  16.       set scrollAmount to pTextLineHeight
  17.     (scrollType = #page):
  18.       set scrollAmount to pWindowHeight / pTextLineHeight * pTextLineHeight
  19.   end case
  20.   if symbolp(direction) then
  21.     case direction of
  22.       #down:
  23.         set scrollDirection to 1
  24.       #up:
  25.         set scrollDirection to -1
  26.     end case
  27.     set scrollVector to scrollAmount * scrollDirection
  28.     set scrollPosition to pWindowTop - the locV of sprite pTextSprite
  29.     set nextScrollPosition to scrollPosition + scrollVector
  30.     if nextScrollPosition > pScrollRange then
  31.       set nextScrollPosition to pScrollRange
  32.     else
  33.       if nextScrollPosition < 0 then
  34.         set nextScrollPosition to 0
  35.       end if
  36.     end if
  37.   else
  38.     set nextScrollPosition to direction * pScrollRange
  39.   end if
  40.   set the locV of sprite pTextSprite to pWindowTop - nextScrollPosition
  41.   sendAllSprites(#positionIndicator, float(nextScrollPosition) / pScrollRange)
  42. end
  43.  
  44. on getPropertyDescriptionList
  45.   set propertyDescriptionList to [#pTextLineHeight: [#comment: "Text Line Height", #format: #integer, #default: 0], #pWindowHeight: [#comment: "Height of Display Window", #format: #integer, #default: 0]]
  46.   return propertyDescriptionList
  47. end
  48.  
  49. on getBehaviorDescription
  50.   return "This behavior scrolls a text sprite in a ", window " when the behavior receives a scrollText message from arrow buttons, a scroll indicator, or the indicator's track. Set the line height and window height parameters to match the height of a line of your text and the height of the your text display area."
  51. end
  52.